﻿using RH.Web.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace RH.Web
{
    public class RouteConfig
    {
        //public static void RegisterRoutes(RouteCollection routes)
        //{
        //    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        //    routes.MapRoute(
        //        name: "Default",
        //        url: "{controller}/{action}/{id}",
        //        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        //    );
        //}

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            var nameFormat = @"[\-\w\d]+";
            //var actionFormat = @"\w+";

            routes.MapRoute(
                name: AppConstants.RouteNames.Public.ITEM_DETAILS,
                url: "product/details/{id}/{productKey}",
                defaults: new { action = "Details", controller = "Product", id = UrlParameter.Optional },
                constraints: new { productKey = nameFormat },
                namespaces: new String[] { "RH.Web.Controllers" }
            );
            //routes.MapRoute(
            //    name: AppConstants.RouteNames.Public.COMPANY_DETAILS,
            //    url: "{CompanyKey}",
            //    defaults: new { controller = "Company", action = "Details" },
            //    constraints: new { CompanyKey = String.Format("({0})", ApplicationCache.CompanyRoutes) },
            //    namespaces: new String[] { "RH.Web.Controllers" }
            //);
            //routes.MapRoute(
            //    name: AppConstants.RouteNames.Public.COMPANY_PRODUCT_DETAILS,
            //    url: "{CompanyKey}/{id}/{productKey}",
            //    //new { controller = "Company", action = "ProductDetails" },
            //    defaults: new { controller = "Product", action = "Details" },
            //    constraints: new { CompanyKey = String.Format("({0})", ApplicationCache.CompanyRoutes), ProductKey = nameFormat },
            //    namespaces: new String[] { "RH.Web.Controllers" }
            //);
            //routes.MapRoute(
            //    name: AppConstants.RouteNames.Public.CONTENT_DETAILS,
            //    url: "{ContentUrl}",
            //    defaults: new { controller = "Content", action = "ViewContent" },
            //    constraints: new { ContentUrl = String.Format("({0})", ApplicationCache.ContentRoutes) },
            //    namespaces: new String[] { "RH.Web.Controllers" }
            //);
            routes.MapRoute(
                name: AppConstants.RouteNames.Public.DEFAULT, // Route name
                url: "{controller}/{action}/{id}", // URL with parameters
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces: new String[] { "RH.Web.Controllers" }
            );
        }
    }
}